home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_06 / allison / ignore.c < prev    next >
C/C++ Source or Header  |  1994-04-08  |  797b  |  41 lines

  1. LISTING 10 - Turns off keyboard interrupt requests
  2.  
  3. /* ignore.c:   Ignores interactive attention key */
  4. #include <stdio.h>
  5. #include <signal.h>
  6.  
  7. main()
  8. {
  9.     char buf[BUFSIZ];
  10.     int i;
  11.  
  12.     /* Ignore keyboard interruptions */
  13.     signal(SIGINT,SIG_IGN);
  14.  
  15.     while (gets(buf))
  16.         puts(buf);
  17.  
  18.     /* Restore default attention key handling
  19.        so the user can abort form the keyboard */
  20.     signal(SIGINT,SIG_DFL);
  21.     for (i = 1; ; ++i)
  22.         printf("%d%c",i,(i%15 ? ' ' : '\n'));
  23. }
  24.  
  25. /* Sample Execution 
  26. c:>ignore
  27. hello
  28. hello
  29. ^C
  30. there
  31. there
  32. ^C
  33. ^Z
  34. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  35. 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  36. 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
  37. 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  38. 61 62 63 64 65 66 67 ^C
  39. */
  40.  
  41.